package com.bj58.mis.apm.server.statistics.dto.cube;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@ApiModel(description = "模型")
@Data
public class Model {
    @ApiModelProperty(value = "模型ID")
    private String id;
    @ApiModelProperty(value = "表名")
    private String table;
    @ApiModelProperty(value = "别名")
    private String alias;
    @ApiModelProperty(value = "维度（表名+列名）")
    private List<String> dimensions;
    @ApiModelProperty(value = "度量（表名+列名）")
    private List<String> metrics;
    @ApiModelProperty(value = "关联表信息")
    private List<Lookup> lookups;


    public String getAlias() {
        if(StringUtils.isNotEmpty(this.alias)){
            return alias;
        }
        if(StringUtils.isNotEmpty(table)){
            if(table.contains(".")){
                return table.substring(table.indexOf(".")+1);
            }
        }
        return table;
    }


}
